package com.gy.universities.service.impl;
import com.gy.universities.dao.StudyAreaMapper;
import com.gy.universities.entity.StudyArea;
import com.gy.universities.service.StudyAreaService;
//import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Component
@Service
public class StudyAreaServiceImpl implements StudyAreaService {

    @Resource
    private StudyAreaMapper studyAreaMapper;

    public StudyArea getStudyAreaById(String id)throws Exception{
        return studyAreaMapper.getStudyAreaById(id);
    }

    public List<StudyArea>	getStudyAreaListByMap(Map<String,Object> param)throws Exception{
        return studyAreaMapper.getStudyAreaListByMap(param);
    }

    public Integer getStudyAreaCountByMap(Map<String,Object> param)throws Exception{
        return studyAreaMapper.getStudyAreaCountByMap(param);
    }

    public Integer qdtxAddStudyArea(StudyArea studyArea)throws Exception{
            //studyArea.setCreatedTime(new Date());
            return studyAreaMapper.insertStudyArea(studyArea);
    }

    public Integer qdtxModifyStudyArea(StudyArea studyArea)throws Exception{
        //studyArea.setUpdatedTime(new Date());
        return studyAreaMapper.updateStudyArea(studyArea);
    }

    public Integer qdtxDeleteStudyAreaById(String id)throws Exception{
        return studyAreaMapper.deleteStudyAreaById(id);
    }

    public Integer qdtxBatchDeleteStudyArea(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return studyAreaMapper.batchDeleteStudyArea(param);
    }


}
